
<!DOCTYPE html>
	<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>注册页面</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="description" content="Free HTML5 Template by FreeHTML5.co" />
	<meta name="keywords" content="free html5, free template, free bootstrap, html5, css3, mobile first, responsive" />
	

  

  	<!-- Facebook and Twitter integration -->
	<meta property="og:title" content=""/>
	<meta property="og:image" content=""/>
	<meta property="og:url" content=""/>
	<meta property="og:site_name" content=""/>
	<meta property="og:description" content=""/>
	<meta name="twitter:title" content="" />
	<meta name="twitter:image" content="" />
	<meta name="twitter:url" content="" />
	<meta name="twitter:card" content="" />

	<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
	<link rel="shortcut icon" href="favicon.ico">

	<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700,300' rel='stylesheet' type='text/css'>
	
	<link rel="stylesheet" href="css/bootstrap.min.css">
	<link rel="stylesheet" href="css/animate.css">
	<link rel="stylesheet" href="css/style.css">

	<!-- Modernizr JS -->
	<script src="js/modernizr-2.6.2.min.js"></script>
	<!-- FOR IE9 below -->
	<!--[if lt IE 9]>
	<script src="js/respond.min.js"></script>
	<![endif]-->
	
	
	</head>
	<body class="style-2">

		<div class="container">
			<div class="row">
				<div class="col-md-4">
					

					<!-- Start Sign In Form -->
					<div class="fh5co-form animate-box" data-animate-effect="fadeInLeft">
						<h2>注册</h2>
					
						<div class="form-group">
							<label for="userName" class="sr-only">姓名</label>
							<input type="text" class="form-control" id="userName" placeholder="姓名" autocomplete="off">
						</div>
						<div class="form-group" name="admin">
							<label for="phone" class="sr-only">手机号</label>
							<input type="phone" class="form-control" id="phone" placeholder="手机号" autocomplete="off">
						</div>
						<div class="form-group">
							<label for="password" class="sr-only">密码</label>
							<input type="password" class="form-control" id="password" placeholder="密码" autocomplete="off">
						</div>
						<div class="form-group">
							<label for="repassword" class="sr-only">确认密码</label>
							<input type="password" class="form-control" id="repassword" placeholder="确认密码" autocomplete="off">
						</div>
						
						
						
						<div class="form-group">
							用户类型：
							<select id="registType">
								<option>普通用户</option>
								<option>场馆馆主</option>
								<option>后台管理员</option>
							</select>
						</div>
						
						<!--<div class="form-group" style="display: none;" name="club">-->
							<!--<label for="clubType" class="sr-only">机构类型</label>-->
							<!--<select id="clubType">-->
								<!--<option>单店</option>-->
								<!--<option>连锁</option>-->
							<!--</select>-->
						<!--</div>-->
						
						<div class="form-group" style="display: none;" name="club">
							<label for="clubName" class="sr-only">机构名称</label>
							<input type="text" class="form-control" id="clubName" placeholder="机构名称" autocomplete="off">
						</div>

						<!--<div class="form-group" style="display: none;" name="club">注册时间：-->
							<!--<label for="clubName" class="sr-only">注册时间</label>-->
							<!--<input type="text" class="form-control" id="regdate"  autocomplete="off" readonly="readonly " >-->
						<!--</div>-->


						<div class="form-group" style="display: none;" name="club">门店展示图片：
							<label for="inputfile" class="sr-only">门店展示图片</label>
							<form method="post" id="file1" enctype="multipart/form-data">
								<input type="file" class="form-control" id="inputfile" name="file">
							</form>
						</div>

						
						<div class="form-group" style="display: none;" name="club" data-toggle="distpicker">
							所在区域：
							<select name="" id="pro"></select>
							<select name="" id="city"></select>
							<select name="" id="area"></select>
						</div>

						<!--<div class="form-group" style="display: none;" name="user">-->
							<!--性别：-->
							<!--<input type="radio" class="form-control" id="sex" name="sex" value="男">男-->
							<!--<input type="radio" class="form-control"  name="sex" value="女">女-->
						<!--</div>-->

						<!--<div class="form-group" style="display: none;" name="user">-->
							<!--出生日期：-->
							<!--<input type="text" class="form-control" id="birthday" placeholder="机构名称" autocomplete="off">-->
						<!--</div>-->

						
						<div class="form-group" name="admin">
							<label for="vcode" class="sr-only">验证码</label>
							<input type="text" class="form-control" id="vcode" placeholder="请填写手机验证码" autocomplete="off">
							<!--<button id="phoneCode">获取手机验证码</button>-->
						</div>
						
						<div class="form-group">
							<p>已经注册? <a href="login.html">登录</a></p>
						</div>
						<div class="form-group">
							<input type="button" value="注册" class="btn btn-primary" id="signupSubmit">
						</div>
					</div>
					<!-- END Sign In Form -->
				</div>

				</div>
			</div>
			<div class="row" style="padding-top: 60px; clear: both;">
				<div class="col-md-12 text-center"><p><small>&copy; All Rights Reserved. More Templates <a href="http://www.cssmoban.com/" target="_blank" title="模板之家">模板之家</a> - Collect from <a href="http://www.cssmoban.com/" title="网页模板" target="_blank">网页模板</a></small></p></div>
			</div>
		</div>
	
	<!-- jQuery -->
	<script src="js/jquery.min.js"></script>
	<!-- Bootstrap -->
	<script src="js/bootstrap.min.js"></script>
	<!-- Placeholder -->
	<script src="js/jquery.placeholder.min.js"></script>
	<!-- Waypoints -->
	<script src="js/jquery.waypoints.min.js"></script>
	<!-- Main JS -->
	<script src="js/main.js"></script>

	<script src="pcajs/distpicker.data.js"></script>
	<script src="pcajs/distpicker.js"></script>

	<script type="text/javascript">
		$(function(){
			$("#registType").change(function(){
				if ($("#registType").val()=="场馆馆主") {
					$("div[name='club']").css("display","");
				}else{
					$("div[name='club']").css("display","none");
				}
                if ($("#registType").val()=="后台管理员") {
                    $("div[name='admin']").css("display","none");
                }else{
                    $("div[name='admin']").css("display","");
                }
			});


		});
	</script>


		<script type="text/javascript">


            $(function(){
                $("#registType").change(function () {

                    function getNow(s) {
                        return s < 10 ? '0' + s: s;
                    }
                    var myDate = new Date();
					//获取当前年
                    var year=myDate.getFullYear();
					//获取当前月
                    var month=myDate.getMonth()+1;
					//获取当前日
                    var date=myDate.getDate();

                    var now=year+'-'+getNow(month)+"-"+getNow(date);

                });


                $('#signupSubmit').click(function(){
                    //获取当前项目


                    //后台管理员注册
                    if($("#registType").val()=="后台管理员"){
                    if($('#userName').val() === ''){
                        alert('用户名不能为空');
                    }else if($('#password').val() === ''){
                        alert('密码不能为空');
                    }else if($('#repassword').val() === ''){
                        alert('确认密码不能为空');
					}else if($('#repassword').val() != $('#password').val()){
                        alert('两次密码输入不一致');
                    }else{
                        $(this).text('请稍后...');

                            $.post(path+"/AdminController/register",
                                {"adminName":$('#userName').val(),
                                    "adminPassword":$('#password').val(),
                                },
                                function(data){
                                    console.log(data);
                                    if(data == "false"){
                                        alert("该用户已被注册");
                                    }else{
                                        window.location.href = "login.html";
                                        return false;
                                    }
                                },"json");
						}

                    }


					//场馆馆主注册
                    if ($("#registType").val()=="场馆馆主") {
                        if($('#userName').val() === ''||$('#phone').val===''||$('#password').val() === ''||$('#repassword').val() === ''||$('#clubName').val()===''||$('#vcode')===''){
                            alert("不能有空");
						}else if($('#repassword').val() != $('#password').val()){
                            alert('两次密码输入不一致');
                        }else{
                            $.post(path+"/ClubController/register",
                                {"clubLinkman":$('#userName').val(),
									"clubPhone":$("#phone").val(),
                                    "clubPassword":$('#password').val(),
                                    "clubCategory":$('#clubType').val(),
                                    "clubName":$('#clubName').val(),
                                    "clubAddress":$('#pro').val()+" "+$('#city').val()+" "+$('#area').val(),
                                    "vcode":$('#vcode').val(),
									"clubImg":imgPWT
                                },
                                function(data){
                                    console.log(data);
                                    if(data == "false"){
                                        alert("该手机号已被注册");
                                    }else{
                                        window.location.href = "login.html";
                                        return false;
                                    }
                                },"json");
						}

                    }



                    //用户注册
                    if ($("#registType").val()=="普通用户") {
                        if($('#userName').val() === ''||$('#phone').val===''||$('#password').val() === ''||$('#repassword').val() === ''||$('#vcode')===''){
                            alert("不能有空");
                        }else if($('#repassword').val() != $('#password').val()){
                            alert('两次密码输入不一致');
                        }else{
                            $.post(path+"/UserController/register",
                                {"userName":$('#userName').val(),
                                    "userPhone":$("#phone").val(),
                                    "userPassword":$('#password').val(),
                                    "vcode":$('#vcode').val(),
                                },
                                function(data){
                                    console.log(data);
                                    if(data == "false"){
                                        alert("该手机号已被注册");
                                    }else{
                                        window.location.href = "login.html";
                                        return false;
                                    }
                                },"json");
                        }

                    }


                });

                // //获取手机验证码
                // $("#phoneCode").click(function () {
                //     $.post(path+"/CodeController/getCode",
                //         {
                //         },
                //         function(data){
                //             console.log(data);
                //             if(data == "false"){
                //                 alert("该用户已注册");
                //             }else{
                //                 window.location.href = "login.html";
                //                 return false;
                //             }
                //         },"json");
                // });


            });
		</script>


		<!--上传图片-->
		<script type="text/javascript">
            var path = "/" + location.pathname.split("/")[1];
			var imgPWT;
            $(function(){ $("#inputfile").change(function () {

                var formData = new FormData($('#file1')[0]);
                console.log(formData==null);
                if(formData==null){
                    alert("请上传图片");
				}
                $.ajax({
                    type: "post",
                    url:path+"/FileImg",
                    data: formData,
					dataType:"json",
                    cache: false,
                    processData: false,
                    contentType: false,
                    beforeSend:function(){

                    },
                    success: function(msg){

                        imgPWT =msg;

                    },
                    error:function(){

                    }
                });



            });

            });

		</script>


	</body>
</html>

